package ThreadDemo;

public class ThreadDemo8 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 100000; i++) {
                System.out.println("计数"+i);
                if (Thread.interrupted()) {//收到信息修改标记
                    System.out.println("线程中断");
                    break;
                }
            }
        });
        t1.start();
        Thread.sleep(100);
        t1.interrupt();//发送信息修改标记
    }
}
